<template>
	<view class="container">
		<view class="navBar-fixed">
			<view :style="{height: statusBarHeight +'px'}"></view>
			<view class="search-container" :style="{height: navBarHeight+'px', width: windowHeight + 'px'}">
				<view class="nav-search" :style="{height:menuButtonHeight+'px'}">
					<text class="nav-search-icon iconfont">&#xea1e;</text>
					<text class="nav-search-text">请输入想要的内容</text>
				</view>
			</view>
		</view>
		<view :style="{height: statusBarHeight + navBarHeight + 'px'}"></view>
	</view>
</template>

<script>
	export default {
		name: 'NavBar',
		created() {
			/* 只在小程序中起作用 */
			// #ifndef APP-PLUS || H5 || MP-ALIPAY
			/* 获取手机系统信息 */
			const info = uni.getSystemInfoSync()
			this.statusBarHeight = info.statusBarHeight
			/* 获取微信胶囊的位置 */
			/* 菜单按键上边界坐标 top
				 菜单按键右边界坐标 right
				 菜单按键下边界坐标 bottom
				 菜单按键左边界坐标 left */
			const menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			this.menuButtonHeight = menuButtonInfo.height
			this.windowHeight = menuButtonInfo.left
			this.navBarHeight = (menuButtonInfo.bottom - info.statusBarHeight) + (menuButtonInfo.top - info
				.statusBarHeight)
			// #endif
		},
		data() {
			return {
				statusBarHeight: 0,
				menuButtonHeight: 32,
				navBarHeight: 44,
				windowHeight: 375
			}
		}
	}
</script>

<style lang="scss">
	.navBar-fixed {
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		background-color: $lws-base-color;
		.search-container {
			display: flex;
			align-items: center;
			justify-content: center;
			box-sizing: border-box;
			width: 100%;
			padding: 0 15px;
			height: 45px;
			.nav-search {
				width: 100%;
				background-color: #fff;
				border-radius: 45rpx;
				display: flex;
				align-items: center;
				height: 32px;
				padding: 0 10px;
				box-sizing: border-box;
			
				.nav-search-icon {
					color: #999;
				}
			
				.nav-search-text {
					color: #999;
					font-size: 14px;
				}
			}
		}
	}
</style>
